package com.pg_chat.model;

import org.apache.poi.xwpf.usermodel.XWPFPicture;

import java.util.Arrays;

public class PicEntity {
    private byte[] pic;
    private int height;
    private int width;
    private int picType;

    public PicEntity() {
    }

    public PicEntity(byte[] pic, int height, int width, int picType) {
        this.pic = pic;
        this.height = height;
        this.width = width;
        this.picType = picType;
    }

    public byte[] getPic() {
        return pic;
    }

    public void setPic(byte[] pic) {
        this.pic = pic;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getPicType() {
        return picType;
    }

    public void setPicType(int picType) {
        this.picType = picType;
    }

    /**
     * 根据POI 3.17版本的XWPFPicture获取对应值
     * XWPFPicture.POIXMLRelation[]
     * @return
     */
    public String PicTypeInPOI(){
        String type = "none";
        switch (this.picType){
            case 2:
                type ="emf";
                break;
            case 3:
                type ="wmf";
                break;
            case 4:
                type ="pict";
                break;
            case 5:
                type ="jpeg";
                break;
            case 6:
                type ="png";
                break;
            case 7:
                type ="dib";
                break;
            case 8:
                type ="gif";
                break;
            case 9:
                type ="tiff";
                break;
            case 10:
                type ="eps";
                break;
            case 11:
                type ="bmp";
                break;
            case 12:
                type ="wpg";
                break;
            default:
                break;
        }
        return type;
    }

    @Override
    public String toString() {
        return "PicEntity{" +
                "pic=" + Arrays.toString(pic) +
                ", height=" + height +
                ", width=" + width +
                ", picType=" + picType +
                '}';
    }
}
